<template>
  <div class="xinpin">
    <div class="xinpin-header">
      <!--<router-link :to="{name: 'shouye/tuijian'}">-->
      <img @click="back" class="back" src="../../assets/img/shouye/header-xinpin/back.png"/>
      <!--</router-link>-->
      <span>本周新品</span>
      <img class="share" src="../../assets/img/shouye/header-xinpin/share.png"/>
    </div>
    <h3>本周新品</h3>
    <h4>精选环球好物</h4>
    <div class="xinpin-input">
      <img src="../../assets/img/shouye/shouye/sousuo.png" height="30" width="28"/>
      <input type="text" placeholder="输入商品关键词">
    </div>
    <ul class="shangpin-ul">
      <li>
        <img src="../../assets/img/shouye/shouye-muying/haibao_mamibaobei.png"/>
        <p>奶粉也要玩有机,养成健康北鼻</p>
        <ul class="list-ul">
          <li>
            <img src="../../assets/img/shouye/shouye-muying/naifen.png"/>
            <p>诺优能幼儿配方奶粉</p>
            <h5>¥59</h5>
          </li>
          <li>
            <img src="../../assets/img/shouye/shouye-muying/naifen.png"/>
            <p>诺优能幼儿配方奶粉</p>
            <h5>¥59</h5>
          </li>
          <li>
            <img src="../../assets/img/shouye/shouye-muying/naifen.png"/>
            <p>诺优能幼儿配方奶粉</p>
            <h5>¥59</h5>
          </li>
        </ul>
      </li>
    </ul>
    <ul class="shangpin-ul">
      <li>
        <img src="../../assets/img/shouye/shouye-muying/haibao_mamibaobei.png"/>
        <p>奶粉也要玩有机,养成健康北鼻</p>
        <ul class="list-ul">
          <li>
            <img src="../../assets/img/shouye/shouye-muying/naifen.png"/>
            <p>诺优能幼儿配方奶粉</p>
            <h5>¥59</h5>
          </li>
          <li>
            <img src="../../assets/img/shouye/shouye-muying/naifen.png"/>
            <p>诺优能幼儿配方奶粉</p>
            <h5>¥59</h5>
          </li>
          <li>
            <img src="../../assets/img/shouye/shouye-muying/naifen.png"/>
            <p>诺优能幼儿配方奶粉</p>
            <h5>¥59</h5>
          </li>
        </ul>
      </li>
    </ul>
    <div class="up" @click="toTop()" v-if="isUP">
      <img src="../../assets/img/shouye/tuijian-xuanliyanzhuang/toTop.png"/>
    </div>
  </div>
</template>
<script>
  export default {
    data () {
      return {
        isUP: false
      }
    },
    methods: {
      back() {
        this.$router.go(-1);
      },
      toTop () {
        if(document.documentElement){
          document.documentElement.scrollTop = 0;
        }else{
          document.body.scrollTop = 0;
        }
      },
      menu() {
        this.scroll = document.documentElement.scrollTop || document.body.scrollTop;
        if(this.scroll > 0){
          //显示 a 标签
          this.isUP = true;
        }else{
          //隐藏 a 标签
          this.isUP = false;
        }
      },
      top () {
        window.scrollTo(0,0)
      }
    },
    mounted() {
      window.addEventListener('scroll', this.menu)
    },
    created () {
      this.top();
    }
  }
</script>
<style scoped>
  .xinpin {
    width: 100%;
    background: #f2f2f2;
    position: relative;
    padding-top: 2rem;
  }

  .xinpin .xinpin-header {
    width: 100%;
    height: 2rem;
    line-height: 2rem;
    background: #e53e42;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10;
  }

  .xinpin .back {
    vertical-align: middle;
    width: 0.6rem;
    margin-left: 0.5rem;
  }

  .xinpin-header span {
    font-family: MicrosoftYaHei;
    font-size: 1rem;
    font-weight: normal;
    font-stretch: normal;
    color: #ffffff;
    margin-left: 5rem;
  }

  .xinpin .share {
    vertical-align: middle;
    margin-left: 3.8rem;
    width: 1rem;
  }

  .xinpin > h3 {
    font-family: MicrosoftYaHei;
    font-size: 1rem;
    font-weight: normal;
    font-stretch: normal;
    color: #e53e42;
    padding: 0.2rem 0 0 0.2rem;
    background: #fff;
  }

  .xinpin > h4 {
    font-family: MicrosoftYaHei;
    font-size: 0.8rem;
    font-weight: normal;
    font-stretch: normal;
    color: #333333;
    padding: 0 0 0.2rem 0.2rem;
    background: #fff;
  }

  .xinpin-input input {
    width: 90%;
    height: 1rem;
    display: block;
    text-align: center;
    margin: 0.5rem auto;
    /*border: 1px solid #ccc;*/
    border-radius: 0.2rem;
  }

  .xinpin-input {
    position: relative;
  }

  .xinpin-input img {
    width: 0.8rem;
    height: 0.8rem;
    position: absolute;
    top: 20%;
    left: 5rem;
  }

  .shangpin-ul {
    background: #fff;
    border-bottom: 1px solid #ccc;
    margin-bottom: 0.5rem;
  }

  .shangpin-ul > li {
    position: relative;
  }

  .xinpin .shangpin-ul > li > img {
    width: 100%;
    height: 9rem;
  }

  .shangpin-ul > li > p {
    text-align: center;
    width: 93.50%;
    color: white;
    font-size: 0.8rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    position: absolute;
    top: 5rem;
    left: 0;
  }

  .xinpin .list-ul {
    display: flex;
    padding: 0 0.5rem;
  }

  .list-ul li {
    flex: 1;
    text-align: center;
  }

  .list-ul li img {
    width: 3rem;
    height: 2rem;
    padding: 0.8rem;
    border: 1px solid #ccc;
  }

  .list-ul li p {
    padding: 0 0.5rem;
    font-family: SimHei;
    font-size: 0.6rem;
    font-weight: normal;
    font-stretch: normal;
    color: #000000;
  }

  .list-ul li h5 {
    font-family: SimHei;
    font-size: 0.7rem;
    font-weight: normal;
    font-stretch: normal;
    color: #e83d41;
  }
  .up {
    width: 1.5rem;
    position: fixed;
    bottom: 0;
    right: 0.3rem;
  }
  .up img {
    width: 100%;
  }
</style>
